<!--
 * @Author: your name
 * @Date: 2020-11-10 15:07:38
 * @LastEditTime: 2020-11-11 17:40:38
 * @LastEditors: Please set LastEditors
 * @Description: 表单封装
 * @FilePath: \vue-admin-beautiful-pro-template\src\components\HH-form.vue
-->
<template>
  <div class="form-container">
    <el-form
      :model="filterObject"
      :label-position="labelPosition"
      :label-width="labelWidth"
    >
      <el-row :gutter="10">
        <el-col
          v-for="item in formData"
          :key="item.prop"
          :span="item.span || 8"
        >
          <el-form-item :label="item.label">
            <el-input
              v-if="item.type === 'text'"
              v-model="filterObject[item.prop]"
              clearable
              :disabled="item.disabled || false"
              :placeholder="item.placeholder"
            ></el-input>

            <el-select
              v-if="item.type === 'select'"
              v-model="filterObject[item.prop]"
              clearable
              :placeholder="item.placeholder"
              @change="handleChange"
            >
              <el-option
                v-for="sub in item.arr"
                :key="sub.value"
                :label="sub.label"
                :value="sub.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
  export default {
    props: {
      formData: {
        type: Array,
        default() {
          return []
        },
      },
      labelPosition: {
        type: String,
        default: 'left',
      },
      labelWidth: {
        type: String,
        default: '80px',
      },
    },
    data() {
      return {
        filterObject: {},
      }
    },
    methods: {
      handleChange() {},
    },
  }
</script>

<style></style>
